package com.xbn.netty.nio;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author XBN
 * @date 2020/10/13 19:30
 * @email 78742541@qq.com
 */
public class FileChannelPic {
    public static void main(String[] args) throws IOException {
        //图片存于项目根目录下
        FileInputStream inputStream = new FileInputStream("java.jpg");
        FileOutputStream outputStream = new FileOutputStream("java2.jpg");
        FileChannel inputStreamChannel = inputStream.getChannel();
        FileChannel outputStreamChannel = outputStream.getChannel();
        outputStreamChannel.transferFrom(inputStreamChannel, 0, inputStreamChannel.size());
        inputStream.close();
        outputStream.close();
    }
}
